Skip to content

feat(serialization): Bringing over the DataStream class from UTP#398

Merged
NoelStephensUnity merged 2 commits intodevelopfrom
feature/datastream_serialization
Dec 7, 2020
Merged

feat(serialization): Bringing over the DataStream class from UTP#398
NoelStephensUnity merged 2 commits intodevelopfrom
feature/datastream_serialization

Conversation

@wackoisgod
Copy link
Copy Markdown
Contributor

@wackoisgod wackoisgod commented Dec 7, 2020

This PR brings in a copy of the DataStream class from the UTP package with some modifications. It removes the NetworkCompressionModel support as well Packed support.

While yes this is code duplication, the DataStream class in UTP is about 100x faster in testing than the current BitWriter/Reader and is job/thread safe and doesn't do any sort of managed allocations or boxing. The reason we are wanting to copy this over instead of putting it into a collection package or something is the DataStream is part of UTP which is also used for DOTS Netcode which would require a bunch of work on new packages and moving things around and bring in Network specific code into Collections which is not going to happen in the near-term. So for now to get the major perf gains this will result in code duplication for a release as we work towards a more perm place for this code to be used across different packages without needing to bring in all of UTP. (potentially a shared networking package between DOTS/Current Unity)

For follow up task to Unify see: DST-188

Changelog

com.unity.multiplayer.mlapi

  • Added: DataStream class is now part of the package

Testing and Documentation

  • Includes unit tests.
  • No documentation changes or additions were necessary.

… some modifications

Bringing over the DataStream class from UTP into the core repo, we remove some of the unused features as well as make it work with some already defined MLAPI types.

This class is also optimized to be used in a job context/burst context and has no managed allocations, as well thread safety.

(Original) https://github.com/Unity-Technologies/netcode/blob/master/com.unity.transport/Runtime/DataStream.cs
Copy link
Copy Markdown
Contributor

@mattwalsh-unity mattwalsh-unity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, given your description I'm not going to scrub this code. Glad to bring this goodness in. Should we have a ticket or something to remember to back it out later?

@wackoisgod
Copy link
Copy Markdown
Contributor Author

@mattwalsh-unity I went ahead and created DST-188 in the Server teams backlog item to figure out a path to Unify the two.

{
"name": "Unity.Multiplayer.MLAPI.Runtime",
"rootNamespace": "MLAPI",
"references": [],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this change necessary? (unsafe is necessary but this one?)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was made by the editor when I changed things via the UI.

}
"hideInEditor": false,
"dependencies": {
"com.unity.collections": "0.14.0-preview.16"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a non-preview one we could use?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, this package is expected to go out of preview in Q1 of 2021. So we shall update it when it comes out of preview (We will need for UTP as well)

Copy link
Copy Markdown
Contributor

@0xFA11 0xFA11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! (with comments)

@NoelStephensUnity NoelStephensUnity merged commit 7dce94a into develop Dec 7, 2020
@0xFA11 0xFA11 deleted the feature/datastream_serialization branch March 5, 2021 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants